<template>
  <!--视图-->
  <div>

    <h1>登录页面</h1>

    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="用户名">
        <el-input v-model="formInline.name" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="formInline.password" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item label="验证码">
        <el-input  v-model="formInline.code" placeholder="验证码"></el-input>
        <el-image :src="imageCodeURL" @click="getImageCodeURL"></el-image>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
      </el-form-item>
    </el-form>

    <a href="
https://gitee.com/oauth/authorize?client_id=
2d20e9427ba1b771a59de64df9f87935ba75f21657013c062dd11576dd483c41
&redirect_uri=
http://192.168.137.196:8888/system/factoryUser/callbackCode
&response_type=code
">gitee登录</a>

  </div>
</template>

<script>
export default {
  name: "FactoryUserView",
  data() {//属性
    return {
      formInline:{},
      imageCodeURL:'',
    }
  }, methods: {//自定义方法
    getImageCodeURL(){
      let uid=sessionStorage.getItem("uid");//获取登录页面的唯一id
      this.formInline.uid=uid;
      this.imageCodeURL='http://localhost:8888/system/factoryUser/createImage?uid='+uid+"&time="+new Date().getTime();//时间戳
    },
    //登录
    login(){
      this.axios.post("system/sysrole/login",this.formInline).then(res=>{
        if(res.data.code==200){
          this.$message.success(res.data.msg);
          localStorage.setItem("token",res.data.data);
          this.$router.push("argpFactory");
        }else {
          this.$message.error(res.data.msg);
        }
      })
    }
  }, created() { //钩子函数
    this.getImageCodeURL();
  }
}
</script>

<style scoped>

</style>